<template>
  <!-- 基础题库 -->
  <div class='container'>
    <el-card>
      <!-- 按钮 -->
      <el-row class="top-btn">
        <el-col :span="12"><span class="text">说明：目前支持学科和关键字条件筛选</span></el-col>
        <el-col :span="12" class="btn-container"><el-button class="add-btn" icon="el-icon-edit" type="success" size="small" @click="$router.push('/questions/new')">新增试题</el-button></el-col>
      </el-row>
  
      <!-- 表单详情 -->
      <el-form ref="searchForms" :model="questionjx" label-position="right" label-width="80px" inline class="catalogs">
        <!-- 第一层 -->
        <el-row>
          <el-col :span="6">
            <el-form-item label="学科" prop='subjectID'>
              <el-select placeholder="请选择" v-model="questionjx.subjectID" @change="getSecondLevel">
                <el-option
                  v-for="(item, index) in subjectList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="二级目录" prop='catalogID'>
              <el-select placeholder="请选择" v-model="questionjx.catalogID" @change="getLabel">
                <el-option
                  v-for="(item, index) in secondLevelList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="标签" prop='tags'>
              <el-select placeholder="请选择" v-model="questionjx.tags">
                <el-option
                  v-for="(item, index) in labelList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="关键字" prop='keyword'>
              <el-input placeholder="请输入" v-model="questionjx.keyword"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第二层 -->
        <el-row>
          <el-col :span="6">
            <el-form-item label="试题类型" prop='questionType'>
            <el-select placeholder="请选择" v-model="questionjx.questionType">
              <el-option
                v-for="(item, index) in questionType"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="难度" prop='difficulty'>
              <el-select placeholder="请选择" v-model="questionjx.difficulty">
                <el-option
                  v-for="(item, index) in difficulty"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="方向" prop='direction'>
              <el-select placeholder="请选择" v-model="questionjx.direction">
                <el-option
                  v-for="(item, index) in direction"
                  :key="index"
                  :label="item"
                  :value="item"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="录入人" prop='creatorID'>
              <el-select placeholder="请选择" v-model="questionjx.creatorID">
                <el-option
                  v-for="(item, index) in username"
                  :key="index"
                  :label="item.username"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第三层 -->
        <el-row>
          <el-col :span="6">
            <el-form-item label="题目备注" prop='remarks'>
              <el-input placeholder="请输入" v-model="questionjx.remarks"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="企业简称" prop='shortName'>
              <el-input placeholder="请输入" v-model="questionjx.shortName"></el-input>
            </el-form-item>
          </el-col>
          <!-- 城市 -->
          <el-col :span="6">
            <el-form-item label="城市" prop='province'>
              <el-col :span="11">
                <el-select placeholder="请选择" v-model="questionjx.province" @change="getCitysList">
                  <el-option
                    v-for="(item, index) in provinceList"
                    :key="index"
                    :label="item"
                    :value="item"
                  ></el-option>
                </el-select>
              </el-col>
              <el-col class="line" :span="2"></el-col>
              <el-col :span="11">
                <el-select placeholder="请选择" v-model="questionjx.city">
                  <el-option
                    v-for="(item, index) in cityList"
                    :key="index"
                    :label="item"
                    :value="item"
                  ></el-option>
                </el-select>
              </el-col>
            </el-form-item>
          </el-col>
          <!-- 按钮 -->
          <el-col :span="6">
            <el-form-item class="last-form-item">
              <el-button class="clear" size="small" @click="clearList">清除</el-button>
              <el-button class="search" size="small" type="primary" @click="searchData">搜索</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <!-- tab栏切换 -->
      <el-tabs type="card" v-model="activeName" @tab-click="handel">
        <!-- 全部 -->
        <el-tab-pane label="全部" name="first">
          <!-- 提示框 -->
          <el-alert
            :title="`数据一共${total}条`"
            type="info"
            :closable= "false"
            show-icon>
          </el-alert>
          <el-table :data="initList" border  class="elTabs">
            <el-table-column width="130" prop="number" label="试题编号">
            </el-table-column>
            <el-table-column
              prop="subject"
              label="学科"
              width="80"
            >
            </el-table-column>
            <el-table-column
              prop="catalog"
              label="目录"
              width="100"  
            >
            </el-table-column>
            <!-- 题型 -->
            <el-table-column
              prop="questionType"
              label="题型"
              width="100"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.questionType === '1'">单选</span>
                <span v-else-if="scope.row.questionType === '2'">多选</span>
                <span v-else>简答</span>
              </template>
            </el-table-column>
            <!-- 题干 -->
            <el-table-column
              prop="question"
              label="题干"
              width="200"  
            >
              <template slot-scope="scope">
                <span v-html="scope.row.question"></span>
              </template>
            </el-table-column>
            <!-- 录入时间 -->
            <el-table-column prop="addDate" label="录入时间" width="200">
              <template slot-scope="scope">
                {{scope.row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column
                  prop="creator"
                  label="录入人"
                  width="100"  
            >
            </el-table-column>
            <!-- 难度 -->
            <el-table-column
              prop="difficulty"
              label="难度"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.difficulty === '1'">简单</span>
                <span v-else-if="scope.row.difficulty === '2'">一般</span>
                <span v-else>困难</span>
              </template>
            </el-table-column>
            <!-- 审核状态 -->
            <el-table-column
              prop="chkState"
              label="审核状态"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.chkState === 0">待审核</span>
                <span v-else-if="scope.row.chkState === 1">通过</span>
                <span v-else>拒绝</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="chkRemarks"
              label="审核意见"
              width="100"  
            >
            </el-table-column>
            <el-table-column
              prop="creator"
              label="审核人"
              width="120"  
            >
            </el-table-column>
            <el-table-column
              prop="publishState"
              label="发布状态"
              width="100"  
            >
              <template slot-scope="scope">
                <span>{{scope.row.publishState === 1 ? '上架' : '下架'}}</span>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              label="操作"
              width="200"
            >
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="getPreview(scope.row)">预览</el-button>
                <el-button type="text" size="small" @click="examineBtn(scope.row.id)" v-if="scope.row.chkState==0">审核</el-button>
                <el-button type="text" size="small" v-else disabled>审核</el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState==0" @click="$router.push({ path: 'new', query: { id: scope.row.id }})">修改</el-button>
                <el-button type="text" size="small" disabled v-else>修改</el-button>
                <el-button type="text" size="small" @click="upperList(scope.row)">
                  <span>{{scope.row.publishState === 1 ? '下架' : '上架'}}</span>
                </el-button>
                <el-button type="text" size="small" @click="deleteBtn(scope.row.id)" v-if="scope.row.publishState==0">删除</el-button>
                <el-button type="text" size="small" disabled v-else>删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <!-- 待审核 -->
        <el-tab-pane label="待审核" name="second">
          <!-- 提示框 -->
          <el-alert
            :title="`数据一共${total}条`"
            type="info"
            :closable= "false"
            show-icon>
          </el-alert>
          <el-table :data="initList" border  class="elTabs">
            <el-table-column width="130" prop="number" label="试题编号">
            </el-table-column>
            <el-table-column
              prop="subject"
              label="学科"
              width="80"
            >
            </el-table-column>
            <el-table-column
              prop="catalog"
              label="目录"
              width="100"  
            >
            </el-table-column>
            <!-- 题型 -->
            <el-table-column
              prop="questionType"
              label="题型"
              width="100"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.questionType === '1'">单选</span>
                <span v-else-if="scope.row.questionType === '2'">多选</span>
                <span v-else>简答</span>
              </template>
            </el-table-column>
            <!-- 题干 -->
            <el-table-column
              prop="question"
              label="题干"
              width="200"  
            >
              <template slot-scope="scope">
                <span v-html="scope.row.question"></span>
              </template>
            </el-table-column>
            <!-- 录入时间 -->
            <el-table-column prop="addDate" label="录入时间" width="200">
              <template slot-scope="scope">
                {{scope.row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column
                  prop="creator"
                  label="录入人"
                  width="100"  
            >
            </el-table-column>
            <!-- 难度 -->
            <el-table-column
              prop="difficulty"
              label="难度"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.difficulty === '1'">简单</span>
                <span v-else-if="scope.row.difficulty === '2'">一般</span>
                <span v-else>困难</span>
              </template>
            </el-table-column>
            <!-- 审核状态 -->
            <el-table-column
              prop="chkState"
              label="审核状态"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.chkState === 0">待审核</span>
                <span v-else-if="scope.row.chkState === 1">通过</span>
                <span v-else>拒绝</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="chkRemarks"
              label="审核意见"
              width="100"  
            >
            </el-table-column>
            <el-table-column
              prop="creator"
              label="审核人"
              width="120"  
            >
            </el-table-column>
            <el-table-column
              prop="publishState"
              label="发布状态"
              width="100"  
            >
              <template slot-scope="scope">
                <span>{{scope.row.publishState === 1 ? '上架' : '下架'}}</span>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              label="操作"
              width="200"
            >
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="getPreview(scope.row)">预览</el-button>
                <el-button type="text" size="small" @click="examineBtn(scope.row.id)" v-if="scope.row.chkState==0">审核</el-button>
                <el-button type="text" size="small" v-else disabled>审核</el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState==0" @click="$router.push({ path: 'new', query: { id: scope.row.id }})">修改</el-button>
                <el-button type="text" size="small" disabled v-else>修改</el-button>
                <el-button type="text" size="small" @click="upperList(scope.row)">
                  <span>{{scope.row.publishState === 1 ? '下架' : '上架'}}</span>
                </el-button>
                <el-button type="text" size="small" @click="deleteBtn(scope.row.id)" v-if="scope.row.publishState==0">删除</el-button>
                <el-button type="text" size="small" disabled v-else>删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <!-- 已审核 -->
        <el-tab-pane label="已审核" name="third">
          <!-- 提示框 -->
          <el-alert
            :title="`数据一共${total}条`"
            type="info"
            :closable= "false"
            show-icon>
          </el-alert>
          <el-table :data="initList" border  class="elTabs">
            <el-table-column width="130" prop="number" label="试题编号">
            </el-table-column>
            <el-table-column
              prop="subject"
              label="学科"
              width="80"
            >
            </el-table-column>
            <el-table-column
              prop="catalog"
              label="目录"
              width="100"  
            >
            </el-table-column>
            <!-- 题型 -->
            <el-table-column
              prop="questionType"
              label="题型"
              width="100"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.questionType === '1'">单选</span>
                <span v-else-if="scope.row.questionType === '2'">多选</span>
                <span v-else>简答</span>
              </template>
            </el-table-column>
            <!-- 题干 -->
            <el-table-column
              prop="question"
              label="题干"
              width="200"  
            >
              <template slot-scope="scope">
                <span v-html="scope.row.question"></span>
              </template>
            </el-table-column>
            <!-- 录入时间 -->
            <el-table-column prop="addDate" label="录入时间" width="200">
              <template slot-scope="scope">
                {{scope.row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column
                  prop="creator"
                  label="录入人"
                  width="100"  
            >
            </el-table-column>
            <!-- 难度 -->
            <el-table-column
              prop="difficulty"
              label="难度"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.difficulty === '1'">简单</span>
                <span v-else-if="scope.row.difficulty === '2'">一般</span>
                <span v-else>困难</span>
              </template>
            </el-table-column>
            <!-- 审核状态 -->
            <el-table-column
              prop="chkState"
              label="审核状态"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.chkState === 0">待审核</span>
                <span v-else-if="scope.row.chkState === 1">通过</span>
                <span v-else>拒绝</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="chkRemarks"
              label="审核意见"
              width="100"  
            >
            </el-table-column>
            <el-table-column
              prop="creator"
              label="审核人"
              width="120"  
            >
            </el-table-column>
            <el-table-column
              prop="publishState"
              label="发布状态"
              width="100"  
            >
              <template slot-scope="scope">
                <span>{{scope.row.publishState === 1 ? '上架' : '下架'}}</span>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              label="操作"
              width="200"
            >
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="getPreview(scope.row)">预览</el-button>
                <el-button type="text" size="small" @click="examineBtn(scope.row.id)" v-if="scope.row.chkState==0">审核</el-button>
                <el-button type="text" size="small" v-else disabled>审核</el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState==0" @click="$router.push({ path: 'new', query: { id: scope.row.id }})">修改</el-button>
                <el-button type="text" size="small" disabled v-else>修改</el-button>
                <el-button type="text" size="small" @click="upperList(scope.row)">
                  <span>{{scope.row.publishState === 1 ? '下架' : '上架'}}</span>
                </el-button>
                <el-button type="text" size="small" @click="deleteBtn(scope.row.id)" v-if="scope.row.publishState==0">删除</el-button>
                <el-button type="text" size="small" disabled v-else>删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <!-- 已拒绝 -->
        <el-tab-pane label="已拒绝" name="four">
          <!-- 提示框 -->
          <el-alert
            :title="`数据一共${total}条`"
            type="info"
            :closable= "false"
            show-icon>
          </el-alert>
          <el-table :data="initList" border  class="elTabs">
            <el-table-column width="130" prop="number" label="试题编号">
            </el-table-column>
            <el-table-column
              prop="subject"
              label="学科"
              width="80"
            >
            </el-table-column>
            <el-table-column
              prop="catalog"
              label="目录"
              width="100"  
            >
            </el-table-column>
            <!-- 题型 -->
            <el-table-column
              prop="questionType"
              label="题型"
              width="100"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.questionType === '1'">单选</span>
                <span v-else-if="scope.row.questionType === '2'">多选</span>
                <span v-else>简答</span>
              </template>
            </el-table-column>
            <!-- 题干 -->
            <el-table-column
              prop="question"
              label="题干"
              width="200"  
            >
              <template slot-scope="scope">
                <span v-html="scope.row.question"></span>
              </template>
            </el-table-column>
            <!-- 录入时间 -->
            <el-table-column prop="addDate" label="录入时间" width="200">
              <template slot-scope="scope">
                {{scope.row.addDate | parseTimeByString}}
              </template>
            </el-table-column>
            <el-table-column
                  prop="creator"
                  label="录入人"
                  width="100"  
            >
            </el-table-column>
            <!-- 难度 -->
            <el-table-column
              prop="difficulty"
              label="难度"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.difficulty === '1'">简单</span>
                <span v-else-if="scope.row.difficulty === '2'">一般</span>
                <span v-else>困难</span>
              </template>
            </el-table-column>
            <!-- 审核状态 -->
            <el-table-column
              prop="chkState"
              label="审核状态"
              width="80"  
            >
              <template slot-scope="scope">
                <span v-if="scope.row.chkState === 0">待审核</span>
                <span v-else-if="scope.row.chkState === 1">通过</span>
                <span v-else>拒绝</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="chkRemarks"
              label="审核意见"
              width="100"  
            >
            </el-table-column>
            <el-table-column
              prop="creator"
              label="审核人"
              width="120"  
            >
            </el-table-column>
            <el-table-column
              prop="publishState"
              label="发布状态"
              width="100"  
            >
              <template slot-scope="scope">
                <span>{{scope.row.publishState === 1 ? '上架' : '下架'}}</span>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              label="操作"
              width="200"
            >
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="getPreview(scope.row)">预览</el-button>
                <el-button type="text" size="small" @click="examineBtn(scope.row.id)" v-if="scope.row.chkState==0">审核</el-button>
                <el-button type="text" size="small" v-else disabled>审核</el-button>
                <el-button type="text" size="small" v-if="scope.row.publishState==0" @click="$router.push({ path: 'new', query: { id: scope.row.id }})">修改</el-button>
                <el-button type="text" size="small" disabled v-else>修改</el-button>
                <el-button type="text" size="small" @click="upperList(scope.row)">
                  <span>{{scope.row.publishState === 1 ? '下架' : '上架'}}</span>
                </el-button>
                <el-button type="text" size="small" @click="deleteBtn(scope.row.id)" v-if="scope.row.publishState==0">删除</el-button>
                <el-button type="text" size="small" disabled v-else>删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <!-- 分页 -->
      <div style="text-align: right;">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="questionjx.page"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="questionjx.pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
      <!-- 审核 -->
      <el-dialog
        class="elDialod"
        title="题目审核"
        :visible.sync="remarksList"
        width="30%">
        <span>
          <el-form :model="shenheData">
            <el-form-item prop="chkState">
              <!-- 单选框按钮 -->
                <el-radio v-model="shenheData.chkState" label="1">通过</el-radio>
                <el-radio v-model="shenheData.chkState" label="2">拒绝</el-radio>
            </el-form-item>
            <el-form-item prop="chkRemarks">
              <!-- 文本输入框 -->
              <el-input
                class="elInput"
                type="textarea"
                :rows="2"
                placeholder="请输入审核意见"
                v-model="shenheData.chkRemarks">
              </el-input>
            </el-form-item>
          </el-form>
        </span>
        <!-- 按钮 -->
        <span slot="footer" class="dialog-footer">
          <el-button @click="remarksList = false">取 消</el-button>
          <el-button type="primary" @click="remarksListBtn">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 预览对话框 -->
        <el-dialog
          v-if="dialogVisible"
          title="题目预览"
          :visible.sync="dialogVisible"
          width="50%"
          >
          <questions-preview :receive="id"></questions-preview>
          <span slot="footer">
            <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
          </span>
        </el-dialog>
    </el-card>
  </div>
</template>

<script>
// 精选题库列表  上下架
import { choice, choicePublish } from '@/api/hmmm/questions'
// 学科
import { simple } from '@/api/hmmm/subjects'
// 二级目录
import { simple as simpleSec } from '@/api/hmmm/directorys'
// 标签
import { simple as tag } from '@/api/hmmm/tags'
// 方向 难度 试题类性  发布状态
import { direction, difficulty, questionType } from '@/api/hmmm/constants'
// 城市
import { provinces, citys } from '@/api/hmmm/citys'
// 录入人
import { simple as simpleUser } from '@/api/base/users'
// 删除
import { remove, choiceCheck } from '@/api/hmmm/questions'
// 预览框
import QuestionsPreview from '../components/questions-preview1'
// 引入时间过滤器
import { parseTimeByString } from '@/filters'

export default {
  name: 'questchoice',
  data () {
    return {
      // 表单 精选题库数据对象
      questionjx: {
        // 学科
        subjectID: null,
        // 二级目录
        catalogID: null,
        // 标签名称
        tags: '',
        // 关键字
        keyword: '',
        // 试题类型
        questionType: '',
        // 难度
        difficulty: '',
        // 方向
        direction: '',
        // 录入人
        creatorID: '',
        // 企业简称
        shortName: '',
        // 方向
        direction: '',
        // 所在城市
        city: '',
        // 所在省份
        province: '',
        // 当前显示的页数
        page: 1,
        // 每页显示的条数
        pagesize: 5,
        id: null,
        chkState: null
      },
      // 学科列表
      subjectList: [],
      // 二级目录列表
      secondLevelList: [],
      // 标签
      labelList: [],
      // 省份
      provinceList: [],
      // 城市
      cityList: [],
      // 方向
      direction,
      // 难度
      difficulty,
      // 试题类型
      questionType,
      // 录入人
      username: '',
      // 搜索表格数据
      tableDataList: [],
      // 审核input框的数据
      textarea: '',
      // 数据总数
      total: null,
      // 初始化数据
      initList: [],
      // 默认显示全部标签页
      activeName: 'first',
      // 审核的数据
      shenheData: {
        id: null,
        chkState: '1',
        chkRemarks: null
      },
      // 预览
      dialogVisible: false,
      // 审核
      remarksList: false,
      currentId: null,
      state: null
    }
  },
  components: {
    QuestionsPreview
  },
  created () {
    // 初始化数据
    this.initialDate()
    // 学科
    this.getSubjectList ()
    // 录入人
    this.getSimpleUser()
  },
  mounted () {
    this.provinceList = provinces()
  },
  methods: {
    // 初始化列表
    async initialDate () {
      const { data } = await choice(this.questionjx)
      // 列表数据
      this.initList = data.items
      // form表单数据
      this.tableDataList = data.items
      // 总条数
      this.total = data.counts
    },
    // 每页的条数
    handleSizeChange (newSize) {
      // console.log(newSize)
      this.questionjx.pagesize = newSize
      this.initialDate()
    },
    // 当前所在的页码
    handleCurrentChange (newPage) {
      console.log(newPage)
      this.questionjx.page = newPage
      this.initialDate()
    },
    // 学科类型列表
    async getSubjectList () {
      const { data } = await simple()
      this.subjectList = data
      // console.log(this.subjectList)
    },
    // 二级目录
    async getSecondLevel () {
      const { data } = await simpleSec({
        subjectID:this.questionjx.subjectID
      })
      this.secondLevelList = data
      // console.log(this.secondLevelList)
    },
    // 标签
    async getLabel () {
      const { data } = await tag({
        subjectID:this.questionjx.subjectID
      })
      this.labelList = data
    },
    // 省份
    getCitysList () {
      this.questionjx.city = ''
      this.cityList = citys(this.questionjx.province)
    },
    // 录入人
    async getSimpleUser () {
      const { data } = await simpleUser()
      this.username = data
    },
    // form表单的清除
    clearList (questionjx) {
      this.$refs.searchForms.resetFields()
      this.initialDate()
    },
    // form表单搜索按钮
    searchData () {
      this.initialDate ()
    },
    // 删除
    deleteBtn (id) {
      // console.log(id)
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
        await remove({ id })
        this.initialDate()
        })
        .catch(() => {
          this.$message.error('取消删除')
        })
    },
    // 审核
    async examineBtn (id) {
      this.remarksList = true
      this.currentId = id
    },
    // 审核对话框提交
    async remarksListBtn () {
      // 审核内容不能为空
      if (!this.shenheData.chkRemarks) {
        return this.$message.warning('请输入审核意见')
      }
      const res = await choiceCheck({
        id: this.currentId,
        chkState: + this.shenheData.chkState,
        chkRemarks: this.shenheData.chkRemarks
      })
      console.log(res)
      this.remarksList = false
      this.chkRemarks = ''
      if (res.status !== 200) return this.$message.error('操作失败')
      this.$message.success('操作成功')
      this.initialDate()
    },
    // 预览
    getPreview (row) {
      this.id = row.id
      this.dialogVisible = true
    },
    // 上下架  publishState发布状态
    async upperList (row) {
      if (row.publishState === 1) {
        this.state = '下架'
      } else {
        this.state = '上架'
      }
      console.log(row.publishState)
        this.$confirm('您确认' + this.state + '这道题目吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(async () => {
          await choicePublish({
            id: row.id,
            publishState: `${row.publishState === 1 ? 0 : 1}`
          })
          console.log(row.publishState)
          this.initialDate()
        })
        .catch(() => {
          this.$message.error('取消' + this.state)
        })
    },
    // 待审核
    handel () {
      console.log(this.activeName)
      if (this.activeName === 'first') {
        this.questionjx.chkState = null
      } else if (this.activeName === 'second') {
        this.questionjx.chkState = 0
      } else if (this.activeName === 'third') {
        this.questionjx.chkState = 1
      } else {
        this.questionjx.chkState = 2
      }
      this.initialDate()
    }
  }
}
</script>

<style lang="less" scoped>
  .container {
    padding: 20px;
    .top-btn {
    margin-bottom: 15px;
    }
    .text {
      font-size: 12px;
      color: #ffc0cb;
    }
    .btn-container {
      text-align: right;
    }
    .last-form-item {
      float: right;
    }
    .el-select {
      width: 100%;
    }
    .catalogs {
      margin-top: 20px;
    }
    .block {
      margin-top: 20px;
    }
    .el-icon-warning {
      clear: red;
    }
    /deep/.el-form-item {
      display: flex;
      flex-direction: row;
    }
    .elTabs {
      margin: 20px 0;
    }
    .el-select {
      width: 100%;
    }
    .el-textarea {
      position: relative;
      display: inline-block;
      width: 100%;
    }
  }
</style>
